﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>LETTER REPLY</title>
		<%@ include file="/share/include.jsp" %>
		<!-- <script src="js/jquery.min.js"></script> -->
   		 <meta name="viewport" content="width=device-width, initial-scale=1">
		 <script type="application/x-javascript"> 
			addEventListener("load", function() { 
				setTimeout(hideURLbar, 0); 
			}, false); 
			function hideURLbar(){ 
				window.scrollTo(0,1); 
			} 
		</script>
		<script type="text/javascript">
			$(function(){
				//表单提交前 验证 表单
		        var letterDemo = $("#replyForm").Validform({
					btnSubmit : "#btn_sub",
					tiptype : function(msg,o,cssctl){
						//msg：提示信息;
						//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
						//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
						if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
							var objtip=o.obj.siblings(".Validform_checktip");
							cssctl(objtip,o.type);
							objtip.text(msg);
						}else{
							var objtip=o.obj.find("#msgLetterDemo");
							cssctl(objtip,o.type);
							objtip.text(msg);
						}
					},
					ajaxPost:true,//ajax异步提交表单
					url:'${root }/control/letter/letterController/replyLetter.do',
					beforeCheck:function(curform){
						 
					 },
					 beforeSubmit:function(data){
						 
					 },callback:function(data){
					 	//alert(data.info);
					 	if(data.status == 'y' && data.info.length == 36){
					 		//$('#letterDiv').hide();
					 		var letterUserId = '${form.letterUserId}';
					 		if(letterUserId != null && letterUserId != ''){
					 			artDalog('Prompt','Stand inside letter reply to success!','${root}/control/letter/letterController/userSentLetterList.do?letterUserId=${form.letterUserId}');
					 		}else{
					 			artDalog('Prompt','Stand inside letter reply to success!','${root}/control/letter/letterController/shopSentLetterList.do?letterShopId=${form.letterShopId}');
					 		}
					 	}else{
					 		artDalog('Prompt','Stand inside letter reply to fail!', null);
					 	}
					 }
				});
				//设置验证成功后的提示信息
				letterDemo.tipmsg.r = 'Through verification!';
			});
		</script>
	</head>
	<body>
		<!-- container -->
		<!-- header -->
		<div class="header">
			<%@ include file="/control/jsp/layout/header.jsp" %>
			<!-- /bottom-header -->
		</div>
		<!-- header -->
		<!--- top-nav -->
			<c:if test="${not empty form.letterUserId }">
				<%@ include file="/control/jsp/layout/userMenu.jsp" %>
			</c:if>
			<c:if test="${not empty form.letterShopId }">
				<%@ include file="/control/jsp/layout/sellerMenu.jsp" %>
			</c:if>
		<!--- top-nav -->
		<!-- Product-Details-page -->
		<div class="details-page">
			<div class="content details-page">
				<div class="product-details">
					<div class="container">
						<div class="details-left" style="width: 100%;margin-top: 20px;">
							<div style="margin-bottom: 10px;">
								<input type="reset" class="p-btn" style="height: 40px;width: 80px;" onclick ="javascript:history.go(-1);" value="Back">
							</div>
						    <c:if test="${letter.letterType == 1}">
						    	<form id="replyForm" action="${root }/control/letter/letterController/replyLetter.do" method="post">
						    		<input type="hidden" name="letterType" value="2" />
						    		<input type="hidden" name="letterUserId" value="${letter.letterUserId }" />
						    		<input type="hidden" name="letterShopId" value="${letter.letterShopId }" />
						    		<input type="hidden" name="letterPrvId" value="${letter.letterId }" />
						    		<input type="hidden" name="letterShopName" value="${letter.letterShopName }" />
						    		<input type="hidden" name="letterUserName" value="${letter.letterUserName }" />
							    	<div style="width: 100%;float: left;padding: 10px 10px 0px 10px;margin-bottom:20px;border-bottom: 1px solid #bac7d2;background-color: #e7f1f7;">
									    <table style="width: 100%;">
									    	<tr height="40px;">
									    		<td width="17%;" align="right"><b>The Title(Reply)  :  </b></td>
									    		<td>
									    			<input type="text" name="letterTitle" style="width: 55%;" value="${fn:escapeXml(letter.letterTitle )}" maxlength="50" dataType="*1-50" nullmsg="Please fill in the title" errormsg="Title length in 1 ~ 50 between!"/>
									    			<span class="Validform_checktip"></span>
									    		</td>
									    	</tr>
									    	<tr height="40px;">
									    		<td width="17%;" align="right"><b>The Sender(Shop)  :  </b></td>
									    		<td><span>${fn:escapeXml(letter.letterShopName)}</span></td>
									    	</tr>
									    	<tr height="40px;">
									    		<td align="right"><span>The Sender Phone：</span></td>
									    		<td>
									    			<input type="text" name="letterPhone" style="width: 55%;" value="${fn:escapeXml(shop.contactTel )}" maxlength="50" dataType="*1-50" nullmsg="Please fill in your phone!" errormsg="Phone length in 1 ~ 50 between!"/>
									    			<span class="Validform_checktip"></span>
									    		</td>
									    	</tr>
									    	<tr height="40px;">
									    		<td align="right"><b class="">The Recipient(User)  :  </b></td>
									    		<td><span>${fn:escapeXml(letter.letterUserName)}</span></td>
									    	</tr>
									    	<tr height="40px;">
									    		<td align="right"><font class="">Order Number  :  </font></td>
									    		<td>
									    			<input type="text" name="letterOrderId" style="width: 55%;" value="${fn:escapeXml(letter.letterOrderId)}" ajaxurl="${root}/control/letter/letterController/checkOrderByUserAndShop.do?letterUserId=${letter.letterUserId }&letterShopId=${shop.shopId}" ignore="ignore" maxlength="14" dataType="*14-14" errormsg="Phone length of 14!" />
									    			<span class="Validform_checktip"></span>
									    		</td>
									    	</tr>
									    </table>
									</div>
									<h4 style="padding-bottom:10px;border-bottom: 1px solid #bac7d2;font-weight: bold;">The Content</h4>
								    <textarea name="letterContent" style="width: 100%; min-height:250px;padding: 20px;border-collapse: inherit;"maxlength="2000" dataType="*1-2000" nullmsg="Please fill in the content!" errormsg="The content length in 1 ~ 2000 between!"> </textarea>
									<span class="Validform_checktip"></span>
									<span id="msgLetterDemo" style="margin-left:30px;"></span><br/>
									<input type="submit" class="p-btn" style="height: 40px;width: 80px;" value="Sender"  />
								</form>
							</c:if>
							 <c:if test="${letter.letterType == 2}">
							 	<form id="replyForm" action="${root }/control/letter/letterController/replyLetter.do" method="post">
						    		<input type="hidden" name="letterType" value="2" />
						    		<input type="hidden" name="letterUserId" value="${letter.letterUserId }" />
						    		<input type="hidden" name="letterShopId" value="${letter.letterShopId }" />
						    		<input type="hidden" name="letterPrvId" value="${letter.letterId }" />
							    	<input type="hidden" name="letterShopName" value="${letter.letterShopName }" />
						    		<input type="hidden" name="letterUserName" value="${letter.letterUserName }" />
							    	<div style="width: 100%;float: left;padding: 10px 10px 0px 10px;margin-bottom:20px;border-bottom: 1px solid #bac7d2;background-color: #e7f1f7;">
									    <table style="width: 100%;">
									    	<tr height="40px;">
									    		<td width="17%;" align="right"><b>The Title(Reply)  :  </b></td>
									    		<td>
									    			<input type="text" name="letterTitle" style="width: 55%;" value="${fn:escapeXml(letter.letterTitle )}" maxlength="50" dataType="*1-50" nullmsg="Please fill in the title" errormsg="Title length in 1 ~ 50 between!"/>
									    			<span class="Validform_checktip"></span>
									    		</td>
									    	</tr>
									    	<tr height="40px;">
									    		<td width="17%;" align="right"><b>The Sender(User)  :  </b></td>
									    		<td><span>${fn:escapeXml(letter.letterUserName)}</span></td>
									    	</tr>
									    	<tr height="40px;">
									    		<td align="right"><span>The Sender Phone：</span></td>
									    		<td>
									    			<input type="text" name="letterPhone" style="width: 55%;" value="${fn:escapeXml(user.userPhone)}" maxlength="50" dataType="*1-50" nullmsg="Please fill in your phone!" errormsg="Phone length in 1 ~ 50 between!"/>
									    			<span class="Validform_checktip"></span>
									    		</td>
									    	</tr>
									    	<tr height="40px;">
									    		<td align="right"><b class="">The Recipient(Shop)  :  </b></td>
									    		<td><span>${fn:escapeXml(letter.letterShopName)}</span></td>
									    	</tr>
									    	<tr height="40px;">
									    		<td align="right"><font class="">Order Number  :  </font></td>
									    		<td>
									    			<input type="text" name="letterOrderId" style="width: 55%;" value="${fn:escapeXml(letter.letterOrderId)}" ajaxurl="${root}/control/letter/letterController/checkOrderByUserAndShop.do?letterUserId=${user.userId }&letterShopId=${letter.letterShopId }" ignore="ignore" maxlength="14" dataType="*14-14" errormsg="Phone length of 14!"/>
									    			<span class="Validform_checktip"></span>
									    		</td>
									    	</tr>
									    </table>
									</div>
									<h4 style="padding-bottom:10px;border-bottom: 1px solid #bac7d2;font-weight: bold;">The Content</h4>
								    <textarea name="letterContent" style="width: 100%; min-height:250px;padding: 20px;border-collapse: inherit;"maxlength="2000" dataType="*1-2000" nullmsg="Please fill in the content!" errormsg="The content length in 1 ~ 2000 between!"> </textarea>
									<span class="Validform_checktip"></span>
									<span id="msgLetterDemo" style="margin-left:30px;"></span><br/>
									<input type="submit" class="p-btn" style="height: 40px;width: 80px;" value="Sender"  />
								</form>
							</c:if>
						</div>
						<div class="clearfix"> </div>
					</div>
			    </div>
		    </div>
		</div>
		<!-- /Product-Details-page -->
		<!-- footer -->
		<%@ include file="/control/jsp/layout/footer.jsp" %>
</body>
</html>

